import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'

const viteBaseConfig = (BASEURL: string) => {
    return defineConfig({
        plugins: [react()],
        optimizeDeps: {
            exclude: []
        },
        server: {
            proxy: {
                '/api': {
                    target: BASEURL,
                    changeOrigin: true,
                    rewrite: path => path.replace(/^\/api/, '')
                }
            }
        },
        resolve: {
            alias: [
                { find: '@', replacement: resolve(__dirname, '../src') }
            ]
        }
    })
}

export default viteBaseConfig